package server.utils;

import java.util.List;

import server.ServerEngin;
import server.jdbc.DAOUtil;
import server.jdbc.JDBCException;

import com.core.async.AsyncObject;

/**
 * 抽象的异步插入数据库
 * @author King
 *
 */
public abstract class AbsAsyncUpdateDb extends AsyncObject
{
	public AbsAsyncUpdateDb(String sql,List params)
	{
		ServerEngin.getInstance().getAsyncService().addAsyncBackWork(this, "update", sql,params);
	}
	
	protected int result;
	
	/**
	 * 异步插入数据库
	 * @param params
	 * @throws JDBCException 
	 */
	public void update(String sql,List params) throws JDBCException 
	{
		DAOUtil dao = DAOUtil.getInstance();
		result = dao.execute(sql, params);
	}
	
	@Override
	public void doCallBack() throws Exception
	{
		updateBack();
	}
	
	/**
	 * 查询完后处理
	 */
	protected abstract void updateBack();
}
